<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3" xmlns:head="http://www.w3.org/1999/html">
<head th:include="public/public_css::public_css ('库存报表')" />
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/jquery.tables.js" type="text/javascript"></script>
<body id="colTb" style="background-color: #f2f2f2;">
<div class="layui-fluid larry-wrapper">
    <div class="layui-card">
        <div class="layui-row layui-col-space30">
            <div class="layui-col-xs24">
                <form class="layui-form layui-card-header  layui-card-header-auto" id="searchForm">
                    <div class="layui-inline">
                        <label class="layui-form-label">货品编号</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="hpbh" name="hpbh" placeholder="货品编号"/>
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">货品名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="hpmc" name="hpmc" placeholder="货品名称"/>
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">库区名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="kqmc" name="kqmc" placeholder="库区名称"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">库位名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="kwmc" name="kwmc" placeholder="库位名称"/>
                        </div>
                    </div>
                    <div class="layui-inline inline-search-btn">
                        <!--<a class="layui-btn layui-btn-normal" data-type="reload" id="search_button"> 搜索 </a>-->
                        <a class="layui-btn layui-btn-normal search_btn" lay-event="searchEvent" data-type="reload">查询</a>

                    </div>
                    <div class="layui-inline inline-reset-btn">
                        <button type="reset" class="layui-btn layui-btn-primary" style="background-color: #1e9fff; color: white;">重置</button>
                    </div>
                    <div class="moreSearch" style="display: none">



                        <div class="layui-inline">
                            <label class="layui-form-label">ASN编号</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" id="asnbh" name="asnbh" placeholder="ASN编号"/>
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">供应商</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" id="gys" name="gysmc" placeholder="供应商"/>
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">货品批次</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" id="hppc" name="hppc" placeholder="货品批次"/>
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">是否包含</label>
                            <select name="kcsl" lay-filter="aihao">
                                <option value=""></option>
                                <option value="0">否</option>
                                <option value="1">是</option>
                            </select>
                        </div>
                    </div>

                </form>
                <div class="moreBtn"><i class="layui-icon layui-icon-triangle-d" style="color: #1E9FFF;"></i></div>

                <!--顶部按钮展示区域 【 tpl-button 】 -->
                <div class="group-button tpl-button" id="toolbar"></div>
                <!--列表-->
                <section class="panel panel-padding layui-card-body">
                    <div class="pro">
                        <table id="table" class="table text-nowrap"></table>
                    </div>
                </section>
            </div>
        </div>
    </div>
</div>
</body>
<div th:include="public/public_js::public_js"></div>
<div th:include="public/public_btn::public_btn"></div>

<script th:inline="javascript">

    var functions = [[${functions}]];
    //	回车查询
    document.onkeydown = function(event) {
        e = event ? event : (window.event ? window.event : null);
        if (e.keyCode == 13) {
            //执行的方法
            $('#search_button').click();
        }
    };

    $(function () {
        $(".moreBtn").on("click",function () {
            $(".moreSearch").toggle();
        })
    });
    layui.use(['list', 'layer', 'zzpUtils', 'jquery', 'laydate', 'tablebutton'], function () {
        var myColumns = [];
        var zzpUtils = layui.zzpUtils,
            $ = layui.jquery,
            laydate = layui.laydate,
            tablebtn = layui.tablebutton;
        tablebtn.buildOnClick({
            type: 1,
            temp: $("#function_tpl"),
            functions: functions.headBtn,
            row: null,
            event: {
                searchEvent: function(){
                    zzpUtils.refreshTable("#table");
                },
                /*导出*/
                exportEvent: function (data) {
                    var arr = [];
                    var $rows = $table.bootstrapTable('getSelections');
                    if ($rows.length > 0) {
                        arr = $.map($rows, function (row) {
                            console.log(row);
                            return row.id;
                        })
                    }
                    /*
                     * 以下是将ids和对象拼接在一起
                     * */
                    var str = zzpUtils.getFormJson($("#searchForm"));
                    var object2 = Object.assign({ids: arr}, str);
                    /*将条件查询和ids传到后台*/
                    zzpUtils.outputXslx({
                        url: "/reports/getstockout",
                        data: JSON.stringify(object2)
                    });
                }
            }
        });
        //初始化
        zzpUtils.webSocket.init();
        laydate.render({
            elem: '#test5'
            ,theme: '#20a0ff'
        })
        var $table = zzpUtils.table({
            elem: '#table',
            isApi: true,
            pagination:true,
            url: '/reports/getstock',
            columns: [{
                field: '',
                checkbox: true
            }, {
                field: 'hpbh',
                title: '货品编号'
            }, {
                field: 'hpmc',
                title: '货品名称'
            }, {
                field: 'gysmc',
                title: '供应商名称'
            }, {
                field: 'hppc',
                title: '货品批次'
            },{
                field: 'kqmc',
                title: '库区名称'
            }, {
                field: 'kwmc',
                title: '库位名称'
            },{
                field: 'sl',
                title: '总数量'
            },{
                field: 'kysl',
                title: '可用数量'
            },{
                field: 'dxjsl',
                title: '待拣货数量'
            },{
                field: 'bhsl',
                title: '待补货数量'
            },{
                field: 'djsl',
                title: '冻结数量'
            },{
                field: 'dzysl',
                title: '待转移数量'
            },{
                field: 'ydsj',
                title: '异动时间'
            },{
                field: 'rksj',
                title: '入库时间'
            },{
                field: 'asnbh',
                title: 'ASN编号'
            }
            ],
            queryParams: function () {//查询条件
                return  zzpUtils.getFormJson($("#searchForm"));
            },
            detailFormatter: function (index, row) {
                return "这里就没有确定过11";
            },

        });
    })

</script>
</html>